{include file="layout/layout" /}
<body style="background-color: #FFF; overflow: auto;"> 
<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3>文章分类</h3>
        <h5>网站文章分类修改</h5>
      </div>
    </div>
  </div>
  <form method="post" class="form-horizontal" id="category_form">
    <div class="ncap-form-default">
      <dl class="row">
        <dt class="tit">
          <label><em>*</em>分类名称</label>
        </dt>
        <dd class="opt">
          <input class="input-txt" name="cat_name" id="cat_name" value="{$res.cat_name}" type="text">
          &nbsp;&nbsp;&nbsp;&nbsp;<span></span>
          <p class="notic"></p>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
          <label for="parent_id">上级分类</label>
        </dt>
        <dd class="opt">
            <select class="small form-control" style="width:200px" tabindex="1"  id="parent_id">
                <option value="0" selected="selected">顶级分类</option>                                 
            </select>        
          <span class="err"></span>
          <p class="notic">暂时不支持多级分类</p>
        </dd>
      </dl>      

      <dl class="row">
        <dt class="tit">
          <label for="ac_sort">排序</label>
        </dt>
        <dd class="opt">
         <!--  <input placeholder="排序"  class="input-txt" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" type="text"> -->
         暂无
          <span class="err"></span>
          <p class="notic"></p>
        </dd>
      </dl>
    <dl class="row">
        <dt class="tit">
          <label for="ac_sort">搜索关键字</label>
        </dt>
        <dd class="opt">暂无
          <!-- <input placeholder="关键字" class="input-txt" type="text"> -->
          <span class="err"></span>
          <p class="notic"></p>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
          <label for="ac_sort">描述</label>
        </dt>
        <dd class="opt">
          <input placeholder="分类描述" name="cat_desc" class="input-txt" type="text" value="{$res.cat_desc}">
          <span class="err"></span>
          <p class="notic"></p>
        </dd>
      </dl>         
      <div class="bot"><a href="javascript:void(0);" onclick="submitForm()" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
    </div>
            <input name="cat_id" value="{$res.cat_id}" type="hidden">  
  </form>
</div>
<script>
  // $('#cat_name').blur(function(){
  //         var v = $(this).val();
  //        if(!(/^1[34578]\d{9}$/.test(v))){
  //             $(this).next().html("<font color='red'>不合法</font>");
  //             return false;
  //         }else{
  //             $(this).next().next().html("<font color='green'>正确</font>");
  //             return ture;
  //         }
  //       })
    function submitForm() {
         var v = $('#cat_name').val();
         if(v == ""){
              $('#cat_name').next().html("<font color='red'>X不合法</font>");
              return false;
          }else{
             $('#cat_name').next().html("<font color='green'>Y正确</font>");
             $.ajax({
            type: "POST",
            url: "{:url('Article/catEdit')}",
            data: $('#category_form').serialize(),
            dataType: "json",
            error: function () {
                layer.alert("服务器繁忙, 请联系管理员!");
            },
            success: function (data) {
               //console.log(data);
                if (data.status == 1) {
                    layer.msg(data.msg, {icon: 1,time: 1000});location.replace(document.referrer);
                }else {
                    layer.msg(data.msg, {icon: 2,time: 1000});location.replace(document.referrer);
                }
            }
          });
        }
        //$('span.err').hide();
        
    }
</script>
</body>
</html>